package com.qunar.wan.support.serializer;

import com.qunar.wan.util.HTMLTagsUtil;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

import java.io.IOException;

/**
 * Created by cyoung on 12/27/13.
 */
public class EscapeSerializer extends JsonSerializer<String> {
    @Override
    public void serialize(String oldStr, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String filteredStr = HTMLTagsUtil.escapeHtml(oldStr, new String[]{"<br>", "</br>"});
        jsonGenerator.writeString(filteredStr);
    }
}